- /* scfcabsH.cpp by K.Tsuru */
- // function ID = 9001
- /***************************************
- SN library
- SComplex class reference
- It returns the absolute value of z in high precision version.
- ****************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SDouble CabsH(const SComplex& z){
- // z = x + iy
- SDouble x( z.Real() ), y( z.Imag() ), r;
- // It takes absolute values.
- if(x.Sign()<0) x.ChangeSign();
- if(y.Sign()<0) y.ChangeSign();
- // z = x+i*y
- if(x.Sign() == 0) return y; // |y|
- if(y.Sign() == 0) return x; // |x|
-
- // |z| = sqrt(x*x+y*y) = |x|*sqrt(1+(y/x)^2) for |x| > |y|
- if(x > y){ // |x|>|y|
- r = y/x;
- r = 1.0 + r*r;
- r = x*Sqrt(r);
- } else { // |x|<=|y|
- r = x/y;
- r = 1.0 + r*r;
- r = y*Sqrt(r);
- }
- return r;
- }
scfcabsH.cpp : last modifiled at 2016/08/04 10:38:21(783 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:08 (Fri Oct 06 15:27:08 2017).